;; Allow easy customization of emacs without restarting it.
(defun edit-dot-emacs ()
  "Load the .emacs file into a buffer for editing."
  (interactive)
  (find-file "~/.emacs.d/dotemacs.el"))

(defun reload-dot-emacs ()
  "Save .emacs, if it is in a buffer, and reload it."
  (interactive)
  (if (bufferp (get-file-buffer "~/.emacs"))
      (save-buffer (get-buffer "~/.emacs")))
  (load-file "~/.emacs.d/dotemacs.el"))

;; Select something that you put in the kill ring ages ago.
(autoload 'browse-kill-ring "browse-kill-ring" "Browse the kill ring." t)
(global-set-key (kbd "C-c k") 'browse-kill-ring)
(eval-after-load "browse-kill-ring"
  '(progn
     (setq browse-kill-ring-quit-action 'save-and-restore)))

(defun insert-today ()
  "Insert today's date into buffer"
  (interactive)
  (insert (format-time-string "%B %e, %Y" (current-time))))

(defun fullscreen-toggle (&optional f)
      (interactive)
      (set-frame-parameter f 'fullscreen
                           (if (frame-parameter f 'fullscreen) nil 'fullboth)))

(defun fullscreen-on ()
(interactive)
(set-frame-parameter nil 'fullscreen 'fullboth))

(defun fullscreen-off ()
(interactive)
(set-frame-parameter nil 'fullscreen nil))

;;;; ----------------------- HELPER FUNCTIONS ------------------------- ;;;;
(defun reset-mode ()
  (interactive)
  (fullscreen-off)
  (intern default-theme)
  (funcall (intern default-theme))
  (emacs-control-reset))

(defun darkroom-mode ()
  "Make things simple-looking by removing decoration 
	 and choosing a simple theme."
  (interactive)
  (fullscreen-on)
  (color-theme-retro-green)  ;; requires color-theme
  (menu-bar-mode -1)
  (set-face-foreground 'mode-line "gray15")
  (set-face-background 'mode-line "black")
  (auto-fill-mode 1)

  (scroll-bar-mode -1)
  (tool-bar-mode -1))

(defun start-writing-mode()
  (interactive)

  ;; We want to automatically wrap paragraphs in LaTeX mode...
  (auto-fill-mode t)
  (filladapt-mode t)

  ;; Set up ispell to do the right thing
  (flyspell-mode t)
  (make-local-variable 'ispell-parser))

(defun emacs-control-reset ()
 (interactive)
 (setq inhibit-startup-message t)
 (delete-selection-mode t)
 (menu-bar-mode -1)
 (line-number-mode t)

 (scroll-bar-mode -1)
 (tool-bar-mode -1))
